capture log close
log using "${path_log}/05_analysis_bop_hh.log", replace
 
use "${path_data}\bophh_final.dta", clear

*** Table 1
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) 	 
add_info inflexppoint, num(1) id(id)
g in_sample = e(sample) == 1  // determine sample
eststo: qui reghdfe inflexppoint tau, absorb(id wave) cluster(id) 
add_info inflexppoint, num(2) id(id) 
eststo: qui did_imputation inflexppoint id wave treatment_time if in_sample == 1, cluster(id) project(price_increase)	 
add_info inflexppoint, num(3) id(id) 
eststo: qui reghdfe inflexppoint tau_price_increase, absorb(id wave) cluster(id) 
add_info inflexppoint, num(4) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, wtr(d_low_increase d_high_increase) autosample cluster(id)
pvalue, num(5)
add_info inflexppoint, num(5) id(id)
drop in_sample

esttab using "${path_export_tables}\table_1.tex", keep(tau tau_price_increase tau_d_low_increase tau_d_high_increase) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("estimator & {BJS}& {TWFE}& {BJS}& {TWFE}& {BJS}\\" "household FE & {yes} & {yes} & {yes}& {yes}& {yes}\\" "month FE & {yes} & {yes} & {yes} & {yes} & {yes}\\" "\midrule"  "$\text{H}_{0}$(coefficients equal): p-value & & & & & ${p5}${diff_stars5}\\" "\midrule" "mean & ${mean1} &${mean2} & ${mean3} & ${mean4}& ${mean5} \\" "N & ${N1} &${N2} & ${N3} & ${N4} & ${N5} \\"  "\# cluster & ${cluster1} &${cluster2} & ${cluster3} & ${cluster4} & ${cluster5} \\" "\bottomrule \bottomrule") nomtitles nonumbers fragment noobs varlabel(tau "treated x post price increase" tau_price_increase "treated x post price increase x 1\% price increase" tau_d_low_increase "treated x post below-median price increase" tau_d_high_increase "treated x post above-median price increase") varwidth(60) substitute("\_" "_") replace

est clear

*** Table 2
qui did_imputation inflexppoint id wave treatment_time if !mi(d_uninformed), autosample cluster(id) nose // determine sample
eststo: qui did_imputation inflexppoint id wave treatment_time if e(sample) == 1, cluster(id) project(d_uninformed_w) maxit(999) fe(id d_informed_w_wave)
add_info inflexppoint, num(1) id(id)
qui did_imputation inflexppoint id wave treatment_time if !mi(d_uninformed,d_educ_high), autosample cluster(id) nose // determine sample
eststo: qui did_imputation inflexppoint id wave treatment_time if e(sample) == 1, cluster(id) project(d_uninformed_w d_educ_high) maxit(999) fe(id d_informed_w_wave d_educ_high_wave)
add_info inflexppoint, num(2) id(id)
qui did_imputation inflexppoint id wave treatment_time if !mi(d_uninformed,d_educ_high,d_inc_high), autosample cluster(id) nose // determine sample
eststo: qui did_imputation inflexppoint id wave treatment_time if e(sample) == 1, cluster(id) project(d_uninformed_w d_educ_high d_inc_high) maxit(999) fe(id d_informed_w_wave d_educ_high_wave d_inc_low_wave)
add_info inflexppoint, num(3) id(id)
qui did_imputation inflexppoint id wave treatment_time if !mi(d_uninformed,d_educ_high,d_inc_high,share_exp_energy), autosample cluster(id) nose // determine sample
eststo: qui did_imputation inflexppoint id wave treatment_time if e(sample) == 1, cluster(id) project(d_uninformed_w d_educ_high d_inc_high share_exp_energy) maxit(999) fe(id d_informed_w_wave d_educ_high_wave d_inc_low_wave d_share_exp_energy_high_wave)
add_info inflexppoint, num(4) id(id)

esttab using "${path_export_tables}\table_2.tex",keep(tau*) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("household FE & {yes} & {yes} & {yes} & {yes}\\" "group x month FE & {yes} & {yes} & {yes} & {yes}\\" "\midrule" "mean & ${mean1} &${mean2} & ${mean3}& ${mean4}\\" "N & ${N1} &${N2} & ${N3} & ${N4} \\" "\# cluster & ${cluster1} &${cluster2} & ${cluster3}& ${cluster4}\\" "\bottomrule \bottomrule") nomtitles nonumbers fragment noobs varlabel(tau_cons "treated x post price increase" tau_d_uninformed_w "treated x post price increase x uninformed about inflation" tau_d_educ_high "treated x post price increase x highly-educated HH" tau_d_inc_high "treated x post price increase x high-income HH" tau_share_exp_energy "treated x post price increase x electricity expenditures (\% of income)") varwidth(50) replace
		
est clear

*** Figure 4	
mat estsave = J(7,3,.)
mat colname estsave = "estmean1" "estmean2" "estmean3"
mat estse = J(7,3,.)
mat colname estse = "estse1" "estse2" "estse3"

*** Event study: full sample
qui did_imputation inflexppoint id wave treatment_time, horizons(0(1)2) pretrends(3) autosample cluster(id)

*** Renormalize pre-trend to pre-treatment period
qui foreach f of numlist 1(1)4 {
	
	if `f' == 1 lincom - pre1
	else	    lincom - pre1 + pre`=5-`f'' 		
	
	mat estsave[`f',1] = `r(estimate)'
	mat estse[`f',1] = `r(se)'

}

*** Post-treatment effects
foreach t of numlist 0(1)2 {
	
	mat estsave[`=`t'+5',1] = e(b)[1,`=`t'+1']
	mat estse[`=`t'+5',1] = `= sqrt(e(V)[`=`t'+1',`=`t'+1']) '
	
} // t

*** Event study: below-median price increase
qui did_imputation inflexppoint id wave treatment_time if d_low_increase == 1, autosample cluster(id) horizons(0(1)2) pretrends(3)

*** Renormalize pre-trend to pre-treatment period
qui foreach f of numlist 1(1)4 {
	
	if `f' == 1 lincom - pre1
	else	    lincom - pre1 + pre`=5-`f'' 		
	
	mat estsave[`f',2] = `r(estimate)'
	mat estse[`f',2] = `r(se)'

}

*** Post-treatment effects
foreach t of numlist 0(1)2 {
	
	mat estsave[`=`t'+5',2] = e(b)[1,`=`t'+1']
	mat estse[`=`t'+5',2] = `= sqrt(e(V)[`=`t'+1',`=`t'+1']) '
	
} // t

*** Event study: above-median price increase
qui did_imputation inflexppoint id wave treatment_time if d_high_increase == 1, autosample cluster(id) horizons(0(1)2) pretrends(3)

*** Renormalize pre-trend to pre-treatment period
qui foreach f of numlist 1(1)4 {
	
	if `f' == 1 lincom - pre1
	else	    lincom - pre1 + pre`=5-`f'' 		
	
	mat estsave[`f',3] = `r(estimate)'
	mat estse[`f',3] = `r(se)'

}

*** Post-treatment effects
foreach t of numlist 0(1)2 {
	
	mat estsave[`=`t'+5',3] = e(b)[1,`=`t'+1']
	mat estse[`=`t'+5',3] = `= sqrt(e(V)[`=`t'+1',`=`t'+1']) '
	
} // t

svmat estsave, names(col)
svmat estse, names(col)

g graphtime1 = _n - 5 - 0.1 if _n <= 7
g graphtime2 = _n - 5  	    if _n <= 7
g graphtime3 = _n - 5 + 0.1 if _n <= 7

forval i = 1/3 {

	g estlb`i' = estmean`i' - invnormal(0.975)*estse`i'
	g estub`i' = estmean`i' + invnormal(0.975)*estse`i' 
	
} // i

twoway (rcap estlb1 estub1 graphtime1 if graphtime1 < -0.15, lcolor(blue) mcolor(blue)) || ///
	   (rcap estlb1 estub1 graphtime1 if graphtime1 >= -0.15, lcolor(blue) mcolor(blue)) || ///
	   (scatter estmean1 graphtime1 if graphtime1 < -0.15, mcolor(blue) msymbol(Oh)) || ///
	   (scatter estmean1 graphtime1 if graphtime1 >= -0.15, mcolor(blue) msymbol(O)) || ///
	   (rcap estlb2 estub2 graphtime2 if graphtime2 < -0.15, lcolor(red) mcolor(red)) || ///
	   (rcap estlb2 estub2 graphtime2 if graphtime2 >= -0.15, lcolor(red) mcolor(red)) || ///
	   (scatter estmean2 graphtime2 if graphtime2 < -0.15, mcolor(red) msymbol(Dh)) || ///
	   (scatter estmean2 graphtime2 if graphtime2 >= -0.15, mcolor(red) msymbol(D)) || ///
	   (rcap estlb3 estub3 graphtime3 if graphtime3 < -0.15, lcolor(purple) mcolor(purple)) || ///
	   (rcap estlb3 estub3 graphtime3 if graphtime3 >= -0.15, lcolor(purple) mcolor(purple)) || ///
	   (scatter estmean3 graphtime3 if graphtime3 < -0.15, mcolor(purple) msymbol(Sh)) || ///
	   (scatter estmean3 graphtime3 if graphtime3 >= -0.15, mcolor(purple) msymbol(S)), ///
	   graphregion(color(white)) bgcolor(white) plotregion(fcolor(white)) ytitle("1-year inflation expectation (in pp)") legend(label(3 "all price increases: placebo test") label(4 "all price increases: dynamic effects") label(7 "below-median price increase: placebo test") label(8 "below-median price increase: dynamic effects") label(11 "above-median price increase: placebo test") label(12 "above-median price increase: dynamic effects") order(3 4 7 8 11 12) rows(3) position(6)) yline(0, lcolor(black)) xlabel(-4(1)2) xscale(titlegap(2)) xtitle("months since price increase") yscale(titlegap(2)) xline(-0.5, lpattern(dash) lcolor(black)) ylabel(-0.5(0.25)1) nodraw

graph display, xsize(20) ysize(11)

graph export "${path_export_graphs}\figure_4.pdf", replace 
	
drop estmean* estse* estlb* estub* graphtime*

*** Figure 5 & Appendix Table B.1 
mat estsave = J(5,4,.)
mat colname estsave =  "estmean" "estse" "estmean_int" "estse_int"

eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) wtr(d_uninformed_w d_informed_w) fe(id d_informed_w_wave) maxit(999)
mat estsave[5,1] = e(b)[1,1]
mat estsave[5,2] = sqrt(e(V)[1,1])
mat estsave[5,3] = e(b)[1,2]
mat estsave[5,4] = sqrt(e(V)[2,2])
pvalue, num(1)
add_info inflexppoint, num(1) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) wtr(d_inc_low d_inc_high) fe(id d_inc_low_wave) maxit(999)
mat estsave[4,1] = e(b)[1,1]
mat estsave[4,2] = sqrt(e(V)[1,1])
mat estsave[4,3] = e(b)[1,2]
mat estsave[4,4] = sqrt(e(V)[2,2])
pvalue, num(2)
add_info inflexppoint, num(2) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) wtr(d_educ_low d_educ_high) fe(id d_educ_high_wave) maxit(999)
mat estsave[3,1] = e(b)[1,1]
mat estsave[3,2] = sqrt(e(V)[1,1])
mat estsave[3,3] = e(b)[1,2]
mat estsave[3,4] = sqrt(e(V)[2,2])
pvalue, num(3)
add_info inflexppoint, num(3) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) wtr(d_renter d_homeowner) fe(id d_homeowner_wave) maxit(999)
mat estsave[2,1] = e(b)[1,1]
mat estsave[2,2] = sqrt(e(V)[1,1])
mat estsave[2,3] = e(b)[1,2]
mat estsave[2,4] = sqrt(e(V)[2,2])
pvalue, num(4)
add_info inflexppoint, num(4) id(id)      
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) wtr(d_low_liquidwealth d_high_liquidwealth) fe(id d_low_liquidwealth_wave) maxit(999)
mat estsave[1,1] = e(b)[1,1]
mat estsave[1,2] = sqrt(e(V)[1,1])
mat estsave[1,3] = e(b)[1,2]
mat estsave[1,4] = sqrt(e(V)[2,2])
pvalue, num(5)
add_info inflexppoint, num(5) id(id)

svmat estsave, names(col)

g graphtime1 = _n + 0.1 if _n <= 5
g graphtime2 = _n - 0.1 if _n <= 5
g estlb = estmean - invnormal(0.975)*estse
g estub = estmean + invnormal(0.975)*estse
g estlb_int = estmean_int - invnormal(0.975)*estse_int
g estub_int = estmean_int + invnormal(0.975)*estse_int

twoway (rcap estlb estub graphtime1, lcolor(blue) mcolor(blue) horizontal) || ///
	   (scatter graphtime1 estmean, lcolor(blue) mcolor(blue) msymbol(O)) || ///
	   (rcap estlb_int estub_int graphtime2, lcolor(red) mcolor(red) horizontal) || ///
	   (scatter graphtime2 estmean_int, lcolor(red) mcolor(red) msymbol(D)), ///
	   xtitle("1-year inflation expectation (in pp)") legend(label(2 "below-median") label(4 "above-median") order(2 4) rows(1) position(6)) xline(0, lcolor(black)) xscale(titlegap(2)) ytitle("") yscale(titlegap(2)) ylabel(1 "liquid wealth" 2 "homeownership" 3 "education" 4 "HH net income" 5 "inflation knowledge", angle(0) nogrid) graphregion(color(white)) bgcolor(white) plotregion(fcolor(white)) xlabel(-0.2(0.2)0.8, nogrid) text(5 0.75 "p-value: ${p1}", size(small)) text(4 0.75 "p-value: ${p2}", size(small)) text(3 0.75 "p-value: ${p3}", size(small)) text(2 0.75 "p-value: ${p4}", size(small)) text(1 0.75 "p-value: ${p5}", size(small)) nodraw

graph display, xsize(20) ysize(11)

graph export "${path_export_graphs}\figure_5.pdf", replace
	
drop estmean* estse* estlb* estub* graphtime*

esttab using "${path_export_tables}\appendix_table_b1.tex", keep(tau*) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("household FE & {yes} & {yes} & {yes}  & {yes} & {yes} \\" "group x month FE & {yes}  & {yes} & {yes}  & {yes}  & {yes}  \\" "\midrule" "$\text{H}_{0}$(coefficients equal): p-value & ${p1}${diff_stars1} & ${p2}${diff_stars2} & ${p3}${diff_stars3} & ${p4}${diff_stars4} & ${p5}${diff_stars5}\\ " "\midrule" "mean & ${mean1} &${mean2} & ${mean3}& ${mean4}  & ${mean5}  \\" "N & ${N1} &${N2} & ${N3} & ${N4}& ${N5} \\" "\# cluster & ${cluster1} &${cluster2} & ${cluster3} & ${cluster4} & ${cluster5} \\" "\bottomrule \bottomrule" ) nomtitles nonumbers fragment noobs varlabel(tau_d_inc_low "treated x post price increase x low-income HH" tau_d_inc_high "treated x post price increase x high-income HH" tau_d_educ_low "treated x post price increase x low education level" tau_d_educ_high "treated x post price increase x high education level" tau_d_low_liquidwealth "treated x post price increase x low liquid wealth" tau_d_high_liquidwealth "treated x post price increase x high liquid wealth" tau_d_informed_w "treated x post price increase x informed about inflation" tau_d_uninformed_w "treated x post price increase x uninformed about inflation" tau_d_renter "treated x post price increase x renter" tau_d_homeowner "treated x post price increase x homeowner") varwidth(55) substitute("\_" "_") replace
		
est clear
 
*** Appendix Table B.3
eststo: qui did_imputation abs_predict_error id wave treatment_time, autosample cluster(id) 
add_info abs_predict_error, num(1) id(id)
eststo: qui did_imputation abs_predict_error_pers id wave treatment_time, autosample cluster(id) 
add_info abs_predict_error_pers, num(2) id(id)
eststo: qui did_imputation abs_difference_spf id wave treatment_time, autosample cluster(id) 
add_info abs_difference_spf, num(3) id(id)
eststo: qui did_imputation sq_predict_error id wave treatment_time, autosample cluster(id) 
add_info sq_predict_error, num(4) id(id)
eststo: qui did_imputation sq_predict_error_pers id wave treatment_time, autosample cluster(id)
add_info sq_predict_error_pers, num(5) id(id)
eststo: qui did_imputation sq_difference_spf id wave treatment_time, autosample cluster(id) 
add_info sq_difference_spf, num(6) id(id)

esttab using "${path_export_tables}\appendix_table_b3.tex", keep(tau) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("household FE & {yes}& {yes} & {yes} & {yes}& {yes} & {yes} \\" "month FE  & {yes}& {yes} & {yes}& {yes}& {yes} & {yes} \\" "\midrule" "mean & ${mean1} &${mean2} & ${mean3} & ${mean4} & ${mean5} & ${mean6} \\" "N & ${N1} &${N2} & ${N3} & ${N4} &${N5} & ${N6}  \\" "\# cluster & ${cluster1} &${cluster2}& ${cluster3}& ${cluster4} &${cluster5}& ${cluster6} \\" "\bottomrule\bottomrule") nomtitles nonumbers fragment noobs varlabel(tau "treated x post price increase") varwidth(30) replace
		
est clear

*** Appendix Table B.4: upper panel
local counter 0

foreach v of varlist inflexppoint5y inflexppoint10y inflexppoint_long incexp_mean incexp_std expint_sav {  
	
	local ++counter
	eststo: qui did_imputation `v' id wave treatment_time, autosample cluster(id)  
	add_info `v', num(`counter') id(id)
 
} // v

esttab using "${path_export_tables}\appendix_table_b4_upper.tex", keep(tau) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("household FE & {yes} & {yes} & {yes} & {yes} & {yes}& {yes}\\" "month FE  & {yes} & {yes} & {yes}  & {yes} & {yes} & {yes} \\" "\midrule" "mean & ${mean1} &${mean2} & ${mean3}& ${mean4}& ${mean5}& ${mean6} \\" "N & ${N1} &${N2} & ${N3} & ${N4}& ${N5}& ${N6} \\" "\# cluster & ${cluster1} &${cluster2} & ${cluster3} & ${cluster4} & ${cluster5} & ${cluster6}  \\" "\midrule") nomtitles nonumbers fragment noobs varlabel(tau "treated x post price increase") varwidth(40) replace

est clear

*** Appendix Table B.4: lower panel		
local counter 0

foreach v of varlist expmacroquali_f expmacroquali_a expmacroquali_g expmacroquali_i expmacroquali_b expmacroquali_x {
	
	local ++counter
	eststo: qui did_imputation `v' id wave treatment_time, autosample cluster(id)  
	add_info `v', num(`counter') id(id)
 
} // v

esttab using "${path_export_tables}\appendix_table_b4_lower.tex", keep(tau) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("household FE & {yes} & {yes} & {yes} & {yes}& {yes} & {yes} \\" "month FE & {yes} & {yes} & {yes} & {yes}& {yes} & {yes} \\"  "\midrule" "mean & ${mean1} &${mean2} & ${mean3}& ${mean4} & ${mean5} & ${mean6}\\" "N & ${N1} &${N2} & ${N3} & ${N4} & ${N5}& ${N6}  \\"  "\# cluster & ${cluster1} &${cluster2} & ${cluster3} & ${cluster4} & ${cluster5}  & ${cluster6}\\" "\bottomrule \bottomrule") nomtitles nonumbers fragment noobs varlabel(tau "treated x post price increase") varwidth(40) replace

est clear

*** Appendix Table B.5 
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id)
add_info inflexppoint, num(1) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) controls(fulltime parttime unemployed retired d_inc_b?_? d_inc_b?_??) maxit(999)
add_info inflexppoint, num(2) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) controls(inflation_l12_pers) maxit(999)
add_info inflexppoint, num(3) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) fe(id llm_wave) maxit(999)
add_info inflexppoint, num(4) id(id)

esttab using "${path_export_tables}\appendix_table_b5.tex", keep(tau) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("household FE  & {yes}& {yes} & {yes} & {yes} \\" "month FE & {yes} & {yes} & {yes} & \\" "employment \& income controls &  & {yes} & & \\" "personal inflation control &   & & {yes} & \\" "local labor market x month FE &  &  &  & {yes}\\"  "\midrule" "mean & ${mean1} &${mean2} & ${mean3} & ${mean4}\\" "N & ${N1} &${N2} & ${N3}  & ${N4}\\" "\# cluster & ${cluster1} &${cluster2} & ${cluster3} & ${cluster4}\\" "\bottomrule \bottomrule") nomtitles nonumbers fragment noobs varlabel(tau "treated x post price increase") varwidth(40) replace
	
est clear 

*** Appendix Table B.6
eststo: qui reg treated gender age east hhsize d_homeowner d_married d_educ_secondary d_educ_intsecondary d_educ_technical d_educ_highschool fulltime parttime unemployed retired d_inc_b*, cluster(id) 
add_info treated, num(1) id(id) 
eststo: qui reg treated gender age east hhsize d_homeowner d_married d_educ_secondary d_educ_intsecondary d_educ_technical d_educ_highschool fulltime parttime unemployed retired d_inc_b* d_wealth_liquid_p?, cluster(id) 
add_info treated, num(2) id(id) 
eststo: qui reg treated gender age east hhsize d_homeowner d_married d_educ_secondary d_educ_intsecondary d_educ_technical d_educ_highschool fulltime parttime unemployed retired d_inc_b* d_wealth_liquid_p? share_durables share_non_durables share_clothes_shoes share_leisure share_mobility share_services share_vacation, cluster(id) 
add_info treated, num(3) id(id) 

esttab using "${path_export_tables}\appendix_table_b6.tex", drop(_cons) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) varlabel(gender "female" east "East Germany" fulltime "employment: full-time" parttime "employment: part-time" unemployed "employment: unemployed" retired "employment: retired" d_inc_b1_2 "household net income: 1000 - 1999\euro" d_inc_b2_3 "household net income: 2000 - 2999\euro" d_inc_b3_4 "household net income: 3000 - 3999\euro" d_inc_b4_5 "household net income: 4000 - 4999\euro" d_inc_b5_6 "household net income: 5000 - 5999\euro" d_inc_b6_10 "household net income: $>$ 6000\euro" d_married "married"  d_educ_secondary "education: secondary school" d_educ_intsecondary "education: intermediate secondary school" d_educ_technical "education: technical school" d_educ_highschool "education: high school" hhsize "household size" d_homeowner "homeowner" share_durables "spending share: durable items (in \%)" share_non_durables "spending share: food \& beverages (in \%)" share_clothes_shoes "spending share: clothes \& shoes (in \%)" share_leisure "spending share: leisure (in \%)" share_mobility "spending share: mobility (in \%)" share_services "spending share: services (in \%)" share_vacation "spending share: vacations (in \%)" share_housing "spending share: housing (in \%)" d_wealth_liquid_p2 "liquid wealth: 25th - 50th percentile" d_wealth_liquid_p3 "liquid wealth: 50th - 75th percentile" d_wealth_liquid_p4 "liquid wealth: $>$ 75th percentile") varwidth(50) nobaselevel postfoot("\midrule" "mean & ${mean1} & ${mean2} & ${mean3} \\" "N & ${N1}& ${N2}  & ${N3}  \\"  "\# cluster & ${cluster1} & ${cluster2}  & ${cluster3} \\" "\bottomrule\bottomrule") nomtitles nonumbers fragment noobs posthead("")  replace

est clear

*** Appendix Table B.7
preserve
 
use "${path_data}\bophh_wdec.dta", clear
 
qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) delta(1) // determine sample 	 
g in_sample = e(sample) == 1 
eststo: qui did_imputation inflexppoint id wave treatment_time if in_sample == 1, cluster(id) project(price_increase) delta(1)  		
add_info inflexppoint, num(1) id(id)
eststo: qui xtscc inflexppoint tau i.wave if d_price_decrease != 1, fe  
add_info inflexppoint, num(2) id(id)
eststo: qui did_imputation inflexppoint_orig id wave treatment_time [aw=wgt_outlier] if d_price_decrease != 1, autosample cluster(id) delta(1) 
add_info inflexppoint_orig, num(3) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time if !inlist(reason_change,2) & d_price_decrease != 1, autosample cluster(id) delta(1)
add_info inflexppoint, num(4) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time if interr == 0 & d_price_decrease != 1, autosample cluster(id) delta(1)
add_info inflexppoint, num(5) id(id)
drop in_sample

esttab using "${path_export_tables}\appendix_table_b7.tex", keep(tau tau_price_increase) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("household FE  & {yes}& {yes} & {yes} & {yes} & {yes}\\" "month FE & {yes} & {yes} & {yes} & {yes} & {yes} \\"  "include price decreases &{yes} &  &  &  & \\" "Driscoll-Kraay standard errors & &  {yes} &  &  & \\" "Huber robust estimation & & & {yes} &  & \\" "drop HHs that switch provider & &  &  & {yes} & \\" "drop HHs that interrupted the survey & & &  &  & {yes} \\" "\midrule" "mean & ${mean1} &${mean2} & ${mean3} & ${mean4} & ${mean5}\\" "N & ${N1} &${N2} & ${N3}  & ${N4}& ${N5} \\" "\# cluster & ${cluster1} &${cluster2} & ${cluster3} & ${cluster4} & ${cluster5} \\" "\bottomrule \bottomrule") nomtitles nonumbers fragment noobs varlabel(tau "treated x post price increase" tau_price_increase "treated x post price increase x 1\% price increase") varwidth(70) replace
	
est clear
 
restore 
	 
*** Appendix Table B.8	
qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) 	 
g in_sample = e(sample) == 1  // determine sample
eststo: qui did_imputation inflexppoint id wave treatment_time if in_sample == 1, cluster(id) project(price_increase)	 
add_info inflexppoint, num(1) id(id) 
eststo: qui did_imputation inflexppoint id wave treatment_time if in_sample == 1, cluster(id) project(price_increase5)	 
add_info inflexppoint, num(2) id(id) 
eststo: qui did_imputation inflexppoint id wave treatment_time if in_sample == 1, cluster(id) project(price_increase10)	 
add_info inflexppoint, num(3) id(id) 
drop in_sample 	

esttab using "${path_export_tables}\appendix_table_b8.tex", keep(tau_price_increase*) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("household FE & {yes} & {yes} & {yes}\\" "month FE & {yes} & {yes} & {yes}\\" "assumption about the open interval & {+ 0} & {+ 5} & {+ 10}\\"  "\midrule" "mean & ${mean1} &${mean2} & ${mean3} \\" "N & ${N1} &${N2} & ${N3}\\"  "\# cluster & ${cluster1} &${cluster2} & ${cluster3} \\" "\bottomrule \bottomrule") nomtitles nonumbers fragment noobs varlabel(tau_price_increase "treated x post price increase x 1\% price increase" tau_price_increase5 "treated x post price increase x 1\% price increase" tau_price_increase10 "treated x post price increase x 1\% price increase") varwidth(60) replace

est clear 
  
*** Appendix Figure B.3 
mat estsave = J(7,2,.)
mat colname estsave =  "estmean_low" "estmean_high" 

mat estse = J(7,2,.)
mat colname estse =  "estse_low" "estse_high"

*** Event study: below-median
qui did_imputation inflexppoint id wave treatment_time if d_uninformed_w == 1, autosample cluster(id) horizons(0(1)2) pretrends(3)

*** Renormalize pre-trend to pre-treatment period
qui foreach f of numlist 1(1)4 {
	
	if `f' == 1 lincom - pre1
	else	    lincom - pre1 + pre`=5-`f'' 		
	
	mat estsave[`f',1] = `r(estimate)'
	mat estse[`f',1] = `r(se)'

}

*** Post-treatment effects
foreach t of numlist 0(1)2 {
	
	mat estsave[`=`t'+5',1] = e(b)[1,`=`t'+1']
	mat estse[`=`t'+5',1] = `= sqrt(e(V)[`=`t'+1',`=`t'+1']) '
	
} // t

*** Event study: above-median
qui did_imputation inflexppoint id wave treatment_time if d_informed_w == 1, autosample cluster(id) horizons(0(1)2) pretrends(3)

*** Renormalize pre-trend to pre-treatment period
qui foreach f of numlist 1(1)4 {
	
	if `f' == 1 lincom - pre1
	else	    lincom - pre1 + pre`=5-`f'' 		
	
	mat estsave[`f',2] = `r(estimate)'
	mat estse[`f',2] = `r(se)'

}

*** Post-treatment effects
foreach t of numlist 0(1)2 {
	
	mat estsave[`=`t'+5',2] = e(b)[1,`=`t'+1']
	mat estse[`=`t'+5',2] = `= sqrt(e(V)[`=`t'+1',`=`t'+1']) '
	
} // t

svmat estsave, names(col)
svmat estse, names(col)

g graphtime1 = _n - 5 - 0.1 if _n <= 7
g graphtime2 = _n - 5 + 0.1 if _n <= 7
g estlb_low = estmean_low - invnormal(0.975)*estse_low
g estub_low = estmean_low + invnormal(0.975)*estse_low
g estlb_high = estmean_high - invnormal(0.975)*estse_high
g estub_high = estmean_high + invnormal(0.975)*estse_high

twoway (rcap estlb_low estub_low graphtime1 if graphtime1 < -0.15, lcolor(blue) mcolor(blue)) || ///
	   (rcap estlb_low estub_low graphtime1 if graphtime1 >= -0.15, lcolor(blue) mcolor(blue)) || ///
	   (scatter estmean_low graphtime1 if graphtime1 < -0.15, mcolor(blue) msymbol(Oh)) || ///
	   (scatter estmean_low graphtime1 if graphtime1 >= -0.15, mcolor(blue) msymbol(O)) || ///
	   (rcap estlb_high estub_high graphtime2 if graphtime2 < -0.15, lcolor(red) mcolor(red)) || ///
	   (rcap estlb_high estub_high graphtime2 if graphtime2 >= -0.15, lcolor(red) mcolor(red)) || ///
	   (scatter estmean_high graphtime2 if graphtime2 < -0.15, mcolor(red) msymbol(Dh)) || ///
	   (scatter estmean_high graphtime2 if graphtime2 >= -0.15, mcolor(red) msymbol(D)), ///
	   graphregion(color(white)) bgcolor(white) plotregion(fcolor(white)) ytitle("1-year inflation expectation (in pp)") legend(label(3 "below-median inflation knowledge: placebo test") label(4 "below-median inflation knowledge: dynamic effects") label(7 "above-median inflation knowledge: placebo test") label(8 "above-median inflation knowledge: dynamic effects") order(3 4 7 8) rows(2) size(*0.925) position(6)) xlabel(-4(1)2) xscale(titlegap(2)) xtitle("months since price increase") yscale(titlegap(2)) xline(-0.5, lpattern(dash) lcolor(black)) ylabel(-0.5(0.25)0.75) yline(0, lcolor(black)) nodraw

graph display, xsize(20) ysize(11)

graph export "${path_export_graphs}\appendix_figure_b3.pdf", replace
	
drop estmean* estse* estlb* estub* graphtime*
	
*** Appendix Figure B.4	
mat estsave = J(7,2,.)
mat colname estsave =  "estmean_low" "estmean_high" 

mat estse = J(7,2,.)
mat colname estse =  "estse_low" "estse_high"

*** Event study: below-median
qui did_imputation inflexppoint id wave treatment_time if d_inc_low == 1, autosample cluster(id) horizons(0(1)2) pretrends(3)

*** Renormalize pre-trend to pre-treatment period
qui foreach f of numlist 1(1)4 {
	
	if `f' == 1 lincom - pre1
	else	    lincom - pre1 + pre`=5-`f'' 		
	
	mat estsave[`f',1] = `r(estimate)'
	mat estse[`f',1] = `r(se)'

}

*** Post-treatment effects
foreach t of numlist 0(1)2 {
	
	mat estsave[`=`t'+5',1] = e(b)[1,`=`t'+1']
	mat estse[`=`t'+5',1] = `= sqrt(e(V)[`=`t'+1',`=`t'+1']) '
	
} // t

*** Event study: above-median
qui did_imputation inflexppoint id wave treatment_time if d_inc_high == 1, autosample cluster(id) horizons(0(1)2) pretrends(3)

*** Renormalize pre-trend to pre-treatment period
qui foreach f of numlist 1(1)4 {
	
	if `f' == 1 lincom - pre1
	else	    lincom - pre1 + pre`=5-`f'' 		
	
	mat estsave[`f',2] = `r(estimate)'
	mat estse[`f',2] = `r(se)'

}

*** Post-treatment effects
foreach t of numlist 0(1)2 {
	
	mat estsave[`=`t'+5',2] = e(b)[1,`=`t'+1']
	mat estse[`=`t'+5',2] = `= sqrt(e(V)[`=`t'+1',`=`t'+1']) '
	
} // t

svmat estsave, names(col)
svmat estse, names(col)

g graphtime1 = _n - 5 - 0.1 if _n <= 7
g graphtime2 = _n - 5 + 0.1 if _n <= 7
g estlb_low = estmean_low - invnormal(0.975)*estse_low
g estub_low = estmean_low + invnormal(0.975)*estse_low
g estlb_high = estmean_high - invnormal(0.975)*estse_high
g estub_high = estmean_high + invnormal(0.975)*estse_high

twoway (rcap estlb_low estub_low graphtime1 if graphtime1 < -0.15, lcolor(blue) mcolor(blue)) || ///
	   (rcap estlb_low estub_low graphtime1 if graphtime1 >= -0.15, lcolor(blue) mcolor(blue)) || ///
	   (scatter estmean_low graphtime1 if graphtime1 < -0.15, mcolor(blue) msymbol(Oh)) || ///
	   (scatter estmean_low graphtime1 if graphtime1 >= -0.15, mcolor(blue) msymbol(O)) || ///
	   (rcap estlb_high estub_high graphtime2 if graphtime2 < -0.15, lcolor(red) mcolor(red)) || ///
	   (rcap estlb_high estub_high graphtime2 if graphtime2 >= -0.15, lcolor(red) mcolor(red)) || ///
	   (scatter estmean_high graphtime2 if graphtime2 < -0.15, mcolor(red) msymbol(Dh)) || ///
	   (scatter estmean_high graphtime2 if graphtime2 >= -0.15, mcolor(red) msymbol(D)), ///
	   graphregion(color(white)) bgcolor(white) plotregion(fcolor(white)) ytitle("1-year inflation expectation (in pp)") legend(label(3 "below-median HH net income: placebo test") label(4 "below-median HH net income: dynamic effects") label(7 "above-median HH net income: placebo test") label(8 "above-median HH net income: dynamic effects") order(3 4 7 8) rows(2) size(*0.925) position(6)) xlabel(-4(1)2) xscale(titlegap(2)) xtitle("months since price increase") yscale(titlegap(2)) xline(-0.5, lpattern(dash) lcolor(black)) ylabel(-0.4(0.2)0.7) yline(0, lcolor(black)) nodraw

graph display, xsize(20) ysize(11)

graph export "${path_export_graphs}\appendix_figure_b4.pdf", replace
	
drop estmean* estse* estlb* estub* graphtime*
 
*** Appendix Figure B.1 & Appendix Table B.2
mat estsave = J(4,4,.)
mat colname estsave =  "estmean" "estse" "estmean_int" "estse_int"
	
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) wtr(d_uninformed d_informed) fe(id d_informed_wave) maxit(999) 
mat estsave[4,1] = e(b)[1,1]
mat estsave[4,2] = sqrt(e(V)[1,1])
mat estsave[4,3] = e(b)[1,2]
mat estsave[4,4] = sqrt(e(V)[2,2])
pvalue, num(1)
add_info inflexppoint, num(1) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) wtr(d_uninformed_w d_informed_w) fe(id d_informed_w_wave) maxit(999) 
mat estsave[3,1] = e(b)[1,1]
mat estsave[3,2] = sqrt(e(V)[1,1])
mat estsave[3,3] = e(b)[1,2]
mat estsave[3,4] = sqrt(e(V)[2,2])
pvalue, num(2)
add_info inflexppoint, num(2) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) wtr(d_uninformed_d d_informed_d) fe(id d_informed_d_wave) maxit(999)
mat estsave[2,1] = e(b)[1,1]
mat estsave[2,2] = sqrt(e(V)[1,1])
mat estsave[2,3] = e(b)[1,2]
mat estsave[2,4] = sqrt(e(V)[2,2])
pvalue, num(3)
add_info inflexppoint, num(3) id(id)
eststo: qui did_imputation inflexppoint id wave treatment_time, autosample cluster(id) wtr(d_uninformed_prs d_informed_prs) fe(id d_informed_prs_wave) maxit(999) 
mat estsave[1,1] = e(b)[1,1]
mat estsave[1,2] = sqrt(e(V)[1,1])
mat estsave[1,3] = e(b)[1,2]
mat estsave[1,4] = sqrt(e(V)[2,2])
pvalue, num(4)
add_info inflexppoint, num(4) id(id)      

svmat estsave, names(col)

g graphtime1 = _n + 0.1 if _n <= 4
g graphtime2 = _n - 0.1 if _n <= 4
g estlb = estmean - invnormal(0.975)*estse
g estub = estmean + invnormal(0.975)*estse
g estlb_int = estmean_int - invnormal(0.975)*estse_int
g estub_int = estmean_int + invnormal(0.975)*estse_int

*** Appendix Figure B.1
twoway (rcap estlb estub graphtime1, lcolor(blue) mcolor(blue) horizontal) || ///
	   (scatter graphtime1 estmean, lcolor(blue) mcolor(blue) msymbol(O)) || ///
	   (rcap estlb_int estub_int graphtime2, lcolor(red) mcolor(red) horizontal) || ///
	   (scatter graphtime2 estmean_int, lcolor(red) mcolor(red) msymbol(D)), ///
	   xtitle("1-year inflation expectation (in pp)") legend(label(2 "below-median") label(4 "above-median") order(2 4) position(6) rows(1)) xline(0, lcolor(black)) xscale(titlegap(2)) ytitle("") yscale(titlegap(2))  ylabel(1 "personal inflation knowledge" 2 `" "inflation knowledge" "net of month FE & demographics" "' 3 `" "inflation knowledge" "net of month FE" "' 4 "inflation knowledge", angle(0) nogrid) xlabel(-0.25(0.25)1, nogrid) graphregion(color(white)) bgcolor(white) plotregion(fcolor(white)) text(4 0.9 "p-value: ${p1}", size(small)) text(3 0.9 "p-value: ${p2}", size(small)) text(2 0.9 "p-value: ${p3}", size(small)) text(1 0.9 "p-value: ${p4}", size(small)) nodraw

graph display, xsize(20) ysize(11)

graph export "${path_export_graphs}\appendix_figure_b1.pdf", replace
	
drop estmean* estse* estlb* estub* graphtime*

esttab using "${path_export_tables}\appendix_table_b2.tex", keep(tau*) star(* 0.1 ** 0.05 *** 0.01) se(3) b(3) posthead("") postfoot("household FE  & {yes} & {yes} & {yes} & {yes} \\" "group x month FE & {yes} & {yes} & {yes} & {yes}\\" "inflation benchmark & {overall inflation} & {overall inflation} & {overall inflation} & {personal inflation} \\" "perception error net of month FE &  &{yes} &{yes} &  \\" "perception error net of demographics &  & &{yes} &  \\"  "\midrule" "$\text{H}_{0}$(coefficients equal): p-value & ${p1}${diff_stars1} & ${p2}${diff_stars2} & ${p3}${diff_stars3} & ${p4}${diff_stars4}\\ " "\midrule" "mean & ${mean1} &${mean2} & ${mean3}& ${mean4} \\" "N & ${N1} &${N2} & ${N3} & ${N4} \\" "\# cluster & ${cluster1} &${cluster2} & ${cluster3} & ${cluster4} \\" "\bottomrule \bottomrule") nomtitles nonumbers fragment noobs varlabel(tau_d_informed_w "treated x post price increase x informed about inflation" tau_d_uninformed_w "treated x post price increase x uninformed about inflation" tau_d_informed "treated x post price increase x informed about inflation" tau_d_uninformed "treated x post price increase x uninformed about inflation" tau_d_informed_d "treated x post price increase x informed about inflation" tau_d_uninformed_d "treated x post price increase x uninformed about inflation" tau_d_informed_prs "treated x post price increase x informed about inflation" tau_d_uninformed_prs "treated x post price increase x uninformed about inflation") varwidth(55) substitute("\_" "_") replace
		
est clear

*** Appendix Graph B.2	
qui did_imputation inflexppoint id wave treatment_time if !mi(share_exp_energy), autosample cluster(id) nose // determine sample
qui did_imputation inflexppoint id wave treatment_time if e(sample) == 1, cluster(id) project(share_exp_energy) maxit(999) fe(id d_share_exp_energy_high_wave)

g exp_share_energy = . 
g exp_share_energy_est = . 
g exp_share_energy_lb = .  
g exp_share_energy_ub = .

local counter 0

qui foreach energy of numlist 0(1)8 {
	
	local ++counter
	replace exp_share_energy = `energy'/100 if _n == `counter'
	qui lincom tau_cons + tau_share_exp_energy * `energy'
	replace exp_share_energy_est = `r(estimate)' if _n == `counter'
	replace exp_share_energy_lb = `r(lb)' if _n == `counter'
	replace exp_share_energy_ub = `r(ub)' if _n == `counter'
	
} // energy

twoway (rarea exp_share_energy_lb exp_share_energy_ub exp_share_energy, fcolor(blue%25) lwidth(none)) || ///
	   (connected exp_share_energy_est exp_share_energy, mcolor(blue) lcolor(blue) msymbol(O)), ///
	   legend(off) ylabel(-0.2(0.1)0.7) xtitle("electricity expenditures (% of income)") ytitle("1-year inflation expectation (in pp)") yscale(titlegap(2)) yline(0, lcolor(black)) nodraw graphregion(color(white)) bgcolor(white) plotregion(fcolor(white)) 

graph display, xsize(20) ysize(11)

graph export "${path_export_graphs}\appendix_figure_b2.pdf", replace
	
drop exp_share_energy*

log close